package org.vectrics.user;

import java.util.Date;

import org.vectrics.common.db.RecordObject;
import org.vectrics.domain.Domain;

public class UserPrivilege implements RecordObject, java.io.Serializable {
	
	public static final long serialVersionUID = 90325235100342646L;
	
	private Long id = null;
	private Person person = null;
	private UserPrivilegeType privType = null;
	private String description = null;
	private Date dateStart = null;
	private Date dateEnd = null;
	private Domain domain = null;
	private boolean childDomains = false;
	
	/**
	 * 
	 */
	public UserPrivilege() {
		super();
	}
	
	public UserPrivilegeType getPrivilegeType() {
		return privType;
	}

	public void setPrivilegeType(UserPrivilegeType role) {
		this.privType = role;
	}

	public String toString() {
		String doStr = "null";
		if ((domain != null) && (domain.getId() != null))
			doStr = domain.getId().toString();
			
		String result = getPerson().getName(); 
		result += "|" + getPrivilegeType();
		result += "|" + doStr;
		return(result);
	}
	
	public int hashCode() {
		return(toString().hashCode());
	} 
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public boolean equals(Object otherObject) {
		boolean result = false;
		UserPrivilege other = (UserPrivilege)otherObject;
		
		if (this.toString().equals(other.toString())) {
			result = true;
		}
		return(result);
	}
	
    /**
     * @return Returns the person.
     */
    public Person getPerson() {
        return person;
    }

    /**
     * @param person The person to set.
     */
    public void setPerson(Person person) {
        this.person = person;
    }
    /**
     * @return Returns the id.
     */
    public Long getId() {
        return id;
    }
    /**
     * @param id The id to set.
     */
    public void setId(Long id) {
        this.id = id;
    }
        
	/**
	 * @return Returns the childDomains.
	 */
	public boolean getGlobal() {
		return childDomains;
	}

	/**
	 * @param childDomains The childDomains to set.
	 */
	public void setGlobal(boolean childDomains) {
		this.childDomains = childDomains;
	}

	/**
	 * @return Returns the dateEnd.
	 */
	public Date getDateEnd() {
		return dateEnd;
	}
	/**
	 * @param dateEnd The dateEnd to set.
	 */
	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}
	/**
	 * @return Returns the dateStart.
	 */
	public Date getDateStart() {
		return dateStart;
	}
	
	/**
	 * @param dateStart The dateStart to set.
	 */
	public void setDateStart(Date dateStart) {
		this.dateStart = dateStart;
	}

	/**
	 * @return Returns the domain.
	 */
	public Domain getDomain() {
		return domain;
	}

	/**
	 * @param domain The domain to set.
	 */
	public void setDomain(Domain domain) {
		this.domain = domain;
	}

}
